---
title: 'Embed'
description: "Embed a memory using BaseAI CLI."
tags:
    - baseai
    - memory
    - langbase
    - embed memory
section: 'Memory'
published: 2024-09-24
modified: 2024-09-24
---

# Embed a Memory

Embed a memory locally using BaseAI CLI.


<Note>
Please make sure to add `OPENAI_API_KEY` to `.env` file in the root of your project. This is required to generate embeddings for the documents in the memory.
</Note>


---

## Step 0 Create memory

Make sure you have a memory [created](/docs/memory/create) a memory and added documents to it.

## Step #1 Embed memory

Embed all memory documents and create a semantic index for the memory. Pass the memory name to the `embed` command using the `--memory` flag or `-m` for short.

```bash
npx baseai@latest embed -m chat-with-docs
```

It will generate embeddings for the documents and create an index for search. Your memory is now ready to be used with a Pipe.

---
